package zjc.bookkeeping.tools;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.NonNull;

import zjc.bookkeeping.R;
import zjc.bookkeeping.minepage.dDatamanagement.DatamanagementMainActivity;

public class TextDialog extends Dialog implements View.OnClickListener {
    TextView fileTv,consumptionTv,businessTv;
    Button sureBtn,cancelBtn;

    public void setTextView(String fileName, String consumptionStr, String businessStr) {
        fileTv.setText(fileName);
        consumptionTv.setText(consumptionStr);
        businessTv.setText(businessStr);
    }

    public interface OnTextSureListener{
        public void onSureListener();
    }
    OnTextSureListener onTextSureListener;

    public void setOnTextSureListener(OnTextSureListener onTextSureListener) {
        this.onTextSureListener = onTextSureListener;
    }
    public interface OnTextCancelListener{
        public void onCancelListener();
    }
    OnTextCancelListener onTextCancelListener;

    public void setOnTextCancelListener(OnTextCancelListener onTextCancelListener) {
        this.onTextCancelListener = onTextCancelListener;
    }

    public TextDialog(@NonNull Context context) {
        super(context);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_text);
        initView();
    }

    private void initView() {
        fileTv = findViewById(R.id.dialog_text_file_tv);
        consumptionTv = findViewById(R.id.dialog_text_consumption_tv);
        businessTv = findViewById(R.id.dialog_text_business_tv);
        cancelBtn = findViewById(R.id.dialog_text_cancel_btn);
        sureBtn = findViewById(R.id.dialog_text_sure_btn);

        cancelBtn.setOnClickListener(this);
        sureBtn.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.dialog_text_cancel_btn:
                cancel();
                onTextCancelListener.onCancelListener();
                break;
            case R.id.dialog_text_sure_btn:
                cancel();
                onTextSureListener.onSureListener();
                break;
        }
    }
}
